package com.cn.yz.springboot.jersey;

public class AcceptToken {

	private static final int TOKEN_LENGTH = 25;
	
	private String token;
	
	public AcceptToken(){
		token = getRandomString(TOKEN_LENGTH);
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}
	
	
	//获取指定位数的随机字符串(包含小写字母、大写字母、数字,0<length)
	private static String getRandomString(int length) {
	    //随机字符串的随机字符库
	    String KeyString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	    StringBuffer sb = new StringBuffer();
	    int len = KeyString.length();
	    for (int i = 0; i < length; i++) {
	       sb.append(KeyString.charAt((int) Math.round(Math.random() * (len - 1))));
	    }
	    return sb.toString();
	}
}
